/**
 * Created by mengxiaxia on 2016/12/18.
 */
var routeApp=angular.module("routeDemo",["ngRoute","ngAnimate"]);
routeApp.controller('HomeController', function ($scope, $route,$http,$timeout) {
    $scope.$route = $route;
    $scope.keycode="";
    $scope.keyname="";
    $scope.createModal=true;
    $scope.order=['tel'];
    $scope.showCreateModal=function () {
        $scope.createModal=false;
    }
    $scope.save=function () {
        $scope.createModal=true;
    }
    $scope.query=function () {
        $scope.createModal=true;
    }
    /** 排序 **/
    $scope.orderBy=function (field) {
        field=field.substring(0,field.length-1);
        if($scope.order.indexOf(field)==-1){
            $scope.order.push(field);
        }else{
            $scope.order.remove(field);
        }
    }
    $http.get("templateUrl/data/org.json").success(function (response) {
        $timeout(function () {
            $scope.orgs = response;
        },1);
    });
});
routeApp.controller('OrgController', function ($scope, $route) { $scope.$route = $route;});
routeApp.controller('UserController', function ($scope, $route) { $scope.$route = $route;});
routeApp.config(["$routeProvider",function ($routeProvider) {
    $routeProvider
        .when("/home",{
            templateUrl:"templateUrl/home.html",
            controller: 'HomeController'
        })
        .when("/org",{
            templateUrl:"org.html",
            controller: 'OrgController'
        })
        .when("/user",{
            templateUrl:"user.html",
            controller: 'UserController'
        })
        .otherwise({
            redirectTo:"/home"
        });
}]);